package service

import (
	"fmt"

	"probe.org/cjd/first/utils"
)

func GetMessages() string {
	var db = utils.GetDb()
	rows, err := db.Query("select * from t_message_2")
	defer rows.Close()

	var sum, n int32

	for rows.Next() {
		if err = rows.Scan(&n); err != nil {
			fmt.Println(err) // Handle scan error
		}
		sum += n // Use result
	}

	// check iteration error
	if rows.Err() != nil {
		fmt.Println(err)
	}

	fmt.Println("sum is %d", sum)
	return "123"
}
